# -*- coding:UTF-8 -*-
import os
import sys

'''
def function1(int):
     print int
     return
A = input("请输入需要的字符串")
function1(A)

def changeList(list):
     "修改传入的列表"
     list.append([1,2,3,4,5])
     print "函数内取值",list
     return
list=[10,20,30,40]
changeList(list)
print "函数外取值",list

def printinfo(name,sex,age=18):
     "打印任何传入的字符"
     print "Name",name
     print "Age",age
     print "Sex",sex
     return
printinfo(name="张三",age=24,sex="女")
printinfo(name="李四",sex="女")
'''
'''
def f1(a,b,c):
     print a,b,c
     return
i=[12,34,890]
f1(*i)

def f2(a,*args):
     print "args",a
     print "args",args
     print '循环输出 args'
     for arg in args:
          print arg
          return sum(args)
     return
f2(12,4564,5784,748)
# 打印字典的值
def f0(A,B,C,D):
     print A,B,C,D
     return
M ={'B':40,'C':6,'D':89}
f0(1,**M)
print ('\n')
# 打印字典
def f3(a,**kw):
     print a
     return
a={'A':4,'B':40,'C':6,'D':89}
f3(a)

def printinfo1(arg1,*vartuple):
     "打印任何传入的参数"
     print "输出："
     print arg1
     for var in vartuple:
          print var
     return
printinfo1(78)
printinfo1(78,789,89,787,99,80)
print ('\n')
sum = lambda arg1,arg2: arg1+arg2
print "相加后的值为：",sum(454,15)
print "相加后的值为：",sum(45412,10234565)

def sum0(arg0,arg00):
     total = arg0 + arg00
     print "函数内：",total
     return total
sum0(256465,9892656)
'''
# 逆序输出
'''
def function(MI):
     for i in range(0,len(MI)/2):
          A=MI[i]
          MI[i]=MI[len(MI)-i-1]
          MI[len(MI)-i-1]=A
          print MI
     print ('\n')
     print MI
MI=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
function(MI)
'''
# 冒泡排序
'''
def function0(K):
     for i in range(0, len(K)):
          for j in range(i+1,len(K)):
               if( K[i] <= K[j]):
                    K[j],K[i]=K[i],K[j]
                    # A = K[i]
                    # K[i] = K[j]
                    # K[j] = A
     print ('\n')
     print K
K = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
function0(K)
'''

'''
def funx(x):
    def funy(y):
        return x * y
    return funy  #return funy返回的是一个对象，可理解为funx是funy的一个对象
print funx(8)(9)
print ("========")

def funx(x):
    def funy(y):
        return x * y
    return funy(52665654)  # return funy()返回的是funy的函数返回值
print funx(1265459)
'''

# 全局变量与局部变量
'''
# ______________________
Money = 2000
def AddMoney():
    global Money
    Money = Money + 1
print Money
AddMoney()
print Money
# ______________________
M0 =100
def Setglobval():
     global M0  # 声明全局变量
     M0 =9987
     M0 = M0+1000
print "输出局部MO:",M0
print ("\n")
Setglobval()
print"输出全局MO:", M0
# ______________________
MMM =100
NNN=3000
FFF=966
def SetGlobal():
     global MMM,NNN,FFF  # 声明全局变量
     MMM =99
     NNN=88
     FFF=77
print "输出定义的变量：",MMM,NNN,FFF
SetGlobal()
print "输出全局的变量：",MMM,NNN,FFF
'''

'''
# raw_input函数
str = raw_input([x*5 for x in range(2,10,2)])
print "你输入的内容是:",str
'''

# 打开文件
# fo = open(r'C:\Users\Administrator\Desktop\readme.txt','r+')
# print fo
# line =fo.read()
# print line
#
# fo = open(r'C:\Users\Administrator\Desktop\readme.txt','a')
# print '文件名：',fo.name
# print "是否已关闭 : ", fo.closed
# print "访问模式 : ", fo.mode
# print "末尾是否强制加空格 : ", fo.softspace

'''
fo = open("foo1.txt", "r")
# fo.write("www.runoob.com!\nVery good site!\n")
str = fo.read(1000)
print "读取的字符串是 : ", str
# 查找当前位置
position = fo.tell()
print "当前文件位置 : ", position

# 把指针再次重新定位到文件开头
position = fo.seek(0, 0)
str = fo.read(20)
print "重新读取字符串 : ", str
# 关闭打开的文件
fo.close()
os.rename("foo1.txt","foo.txt")
print fo.name
'''


# 创建文件读取文件、
def Createdfile(name1,vaule):
    desktop_path = r'D:\PythonStandy'
    full_Path = desktop_path  + name1 +'.txt'
    fo = open(full_Path,'wb')
    print fo.name
    fo.write("AAAAVVVV")
    # position = fo.seek(30000000000, 30000)
    fo.write("豫章故郡，洪都新府。星分翼轸，地接衡庐。襟三江而带五湖， 控蛮荆而引瓯越.物华天宝， 龙光射牛斗之墟； 人杰地灵， 徐孺下陈蕃之榻。 雄州雾列， 俊采星驰。")
    print str
    fo.close()
    # os.remove("test0.txt")

# # 函数功能:创建一个txt文件，文件名为name,并向文件写入msg
# def text_create(name1, msg):
#     desktop_path = r'D:\PythonStandy'
#     full_Path = desktop_path + name1 + '.txt'
#     fo = open(full_Path, 'wb')
#     file.write("豫章故郡，洪都新府。星分翼轸，地接衡庐。襟三江而带五湖， 控蛮荆而引瓯越.物华天宝， 龙光射牛斗之墟")
#     print('=======')
